Declaration of variables based on an interface
Syntax |
---|
|
Meaning | |
---|---|
declaration of one or more →variables based on an →interface (a feature of the →object-oriented programming)
|
The declaration of variables based on an interface is possible within these sections:
(Consult the respective description of the section about possibly additional possibilities for the variable.)
Section |
The declaration of the variable is done as: |
---|---|
|
internal variable (see "Declaration of internal variables in ST") |
|
input variable (see "Declaration of input variables in ST") |
|
output variable (see"Declaration of output variables in ST") |
|
as structure element (see"Declaration of a structured data type in ST") |
Deviation form IEC-standard In Neuron it is not possible to declare variables based on an interface within the section for →temporary variables ( |
Assignments to variables based on an interface
→Assignments to variables based on an interface are possible – as usual – by using this operator: :=
Moreover, Neuron Power Engineer supports the assignment operator "?=
" (see "Assignment attempt in ST" for details).
Syntax for assignments:
Syntax |
---|
|
The expression on the right side of the assignment operator ":=
" may be one of the following constructs:
-
an →instance of a →function block type or of a →class that is implementing the same interface or that has been derived from a base function block or class implementing the same interface
-
another declared variable based on the same or a derived interface
-
NULL
Examples on using interfaces and variables based on these interfaces (incl. assignments)
Example 1 |
---|
|
Compare:
-
The above assignment
i_Switch := switchVal;
is correct. Reason: The function block instanceswitchVal
is assigned to the variablei_Switch
that is based on the interfaceISwitch
. The function blockMySwitch
implements this interfaceISwitch
. -
The assignment
i_Switch := fbinst;
would be highlighted as faulty. Reason: Although the function block instancefbinst
is assigned to the same variablei_Switch
, the function blockmyFB
does not implement the interfaceISwitch
.
Example 2 |
---|
|